package 动态规划;

public class p牛客JZ10斐波那契数列 {
    public int Fibonacci(int n) {
        //动态规划

        //1.存储子问题的解
        int[] res=new int[n+1];
        res[0]=0;
        res[1]=1;

        //2.状态转移方程
        //res[i]=res[i-1]+res[i-2]
        for (int i = 2; i <= n; i++) {
            res[i]=res[i-1]+res[i-2];
        }

        //4.返回结果
        return res[n];

    }
}
